﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using model;
using System.Data;

namespace Dal
{
    public class ResumeDal
    {
        public Resume GetSingle(string sno)
        {
            string sql="select * from Resume where sno='"+sno+"'";
            DataSet ds= DbSqlHelper.Query(sql);
            Resume resume = new Resume();
            DataRow row=ds.Tables[0].Rows[0];
            resume.Rno = Convert.ToInt32(row["rno"]);
            resume.Xueli = row["xueli"].ToString();
            resume.Huji = row["huji"].ToString();
            resume.Tele = row["tele"].ToString();
            resume.Mobile = row["moblie"].ToString();
            resume.Addr = row["addr"].ToString();
            resume.Yixiang = row["yixiang"].ToString();
            resume.Record = row["record"].ToString();
            resume.Inter = row["inter"].ToString();
            resume.Intro = row["intro"].ToString();
            resume.Sno = row["sno"].ToString();
            return resume;
        }
        public void Insert(string sno)
        {
            string sql = string.Format("insert into Resume(sno,xueli,huji) values('{0}','本科',' ')",sno);
            DbSqlHelper.ExecuteSql(sql);
        }
        public void Update(Resume resume)
        {
            string sql = string.Format("update Resume set xueli='{0}',huji='{1}',tele='{2}',addr='{3}',yixiang='{4}',record='{5}',inter='{6}',intro='{7}',moblie='{8}' where sno='{9}'",resume.Xueli,resume.Huji,resume.Tele,resume.Addr,resume.Yixiang,resume.Record,resume.Inter,resume.Intro,resume.Mobile,resume.Sno);
            DbSqlHelper.ExecuteSql(sql);
        }
        public void Delete(string sno)
        {
            string sql = "delete from Resume where sno='" + sno + "'";
            DbSqlHelper.ExecuteSql(sql);
        }
        public int ClearResume(string sno)
        {
            string sql = "update Resume set tele='',moblie='',addr='',yixiang='',record='',inter='',intro='' where sno='" + sno + "'";
            return DbSqlHelper.ExecuteSql(sql);
        }
    }
}
